<!--
 * @Author: panghu chenjh@datamargin.com
 * @Date: 2024-04-03 09:40:13
 * @LastEditors: panghu chenjh@datamargin.com
 * @LastEditTime: 2024-05-03 17:27:46
 * @FilePath: \zheye\src\App.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="container">
    <Loader v-if="isLoading" text="正在拼命加载" background="rgba(0, 0, 0, .8)">正在加载</Loader>
    <GlobalHeader :user="user"></GlobalHeader>
    <router-view></router-view>
    <footer class="text-center py-4 text-secondary bg-light mt-6">
      <small>
        <ul class="list-inline mb-0">
          <li class="list-inline-item">2020 者也专栏</li>
          <li class="list-inline-item">课程</li>
          <li class="list-inline-item">文档</li>
          <li class="list-inline-item">联系</li>
          <li class="list-inline-item">更多</li>
        </ul>
      </small>
    </footer>
  </div>
</template>

<script lang="ts">
import { defineComponent, computed, onMounted, watch } from 'vue'

import GlobalHeader from './components/GlobalHeader.vue'
import { useStore } from 'vuex'
import { GlobalDataProps } from '@/store'
import Loader from '@/components/Loader.vue'
import CreateMessage from '@/components/createMessage'
import 'bootstrap/dist/css/bootstrap.min.css'

export default defineComponent({
  name: 'App',
  components: {
    GlobalHeader,
    Loader
  },
  setup () {
    const store = useStore<GlobalDataProps>()
    const user = computed(() => {
      return store.state.user
    })
    const error = computed(() => {
      return store.state.error
    })
    const isLoading = computed(() => store.state.loading)
    watch(error, () => {
      const { status, message } = error.value
      if (status && message) {
        CreateMessage(message, 'error')
      }
    })
    return {
      user,
      error,
      isLoading
    }
  }
})
</script>

<style></style>
